package com.ruoyi.develop.factory.factoryLibraryProduct.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.develop.factory.factoryLibraryProduct.domain.FactoryLibraryProduct;
import com.ruoyi.develop.factory.factoryLibraryProduct.service.IFactoryLibraryProductService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 产成品库Controller
 * @author lmm
 * @date 2024-11-06
 */
@RestController
@RequestMapping("/factoryLibraryProduct/factoryLibraryProduct")
public class FactoryLibraryProductController extends BaseController {
    @Autowired
    private IFactoryLibraryProductService factoryLibraryProductService;

    /**
     * 查询产成品库列表
     */
    @PreAuthorize("@ss.hasPermi('develop:FactoryLibraryProduct:query')")
    @GetMapping("/list")
    public TableDataInfo list(FactoryLibraryProduct entity) {
        startPage();
        List<FactoryLibraryProduct> list = factoryLibraryProductService.selectList(entity);
        return getDataTable(list);
    }

    /**
     * 导出产成品库列表
     */
    @PreAuthorize("@ss.hasPermi('develop:FactoryLibraryProduct:export')")
    @Log(title = "产成品库", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, FactoryLibraryProduct entity) {
        List<FactoryLibraryProduct> list = factoryLibraryProductService.selectList(entity);
        ExcelUtil<FactoryLibraryProduct> util = new ExcelUtil<FactoryLibraryProduct>(FactoryLibraryProduct. class);
        util.exportExcel(response, list, "产成品库数据");
    }

    /**
     * 获取产成品库详细信息
     */
    @PreAuthorize("@ss.hasPermi('develop:FactoryLibraryProduct:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id) {
        return AjaxResult.success(factoryLibraryProductService.selectById(id));
    }

    /**
     * 新增产成品库
     */
    @PreAuthorize("@ss.hasPermi('develop:FactoryLibraryProduct:add')")
    @Log(title = "产成品库", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    public AjaxResult add(@RequestBody FactoryLibraryProduct entity) {
        return toAjax(factoryLibraryProductService.insert(entity));
    }

    /**
     * 修改产成品库
     */
    @PreAuthorize("@ss.hasPermi('develop:FactoryLibraryProduct:edit')")
    @Log(title = "产成品库", businessType = BusinessType.UPDATE)
    @PutMapping("/edit")
    public AjaxResult edit(@RequestBody FactoryLibraryProduct entity) {
        return toAjax(factoryLibraryProductService.update(entity));
    }

    /**
     * 删除产成品库
     */
    @PreAuthorize("@ss.hasPermi('develop:FactoryLibraryProduct:remove')")
    @Log(title = "产成品库", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids) {
        return toAjax(factoryLibraryProductService.deleteByIds(ids));
    }
}
